package com.hqyj.yanguangzhi.controller;

import com.hqyj.common.pojo.SysUser;
import com.hqyj.common.util.CommonResult;
import com.hqyj.yanguangzhi.service.OEService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.UUID;

/**
 * YanGG    在线考试
 *
 * @ClassName: OEController
 * @author: yanguangzhi
 * @date: 2021/10/21 9:24
 */
@RestController
@RequestMapping("/oe")
public class OEController {
    @Autowired
    private OEService oeService;

    @GetMapping("/get_topic")
    public CommonResult getTopic() {
        return oeService.queryRandomTopic();
    }

    @PostMapping("/put_answer")
    public CommonResult putAnswer(String one, String two, String zero
            , String shortTopic, HttpSession session) {
//        SysUser user = (SysUser) session.getAttribute("user");
        SysUser user = new SysUser();
        user.setUserId(17);
        user.setName("yanguangzhi");
        String testPaperName = user.getName() + "+模拟考试+" + UUID.randomUUID();
        return oeService.putAnsWer(testPaperName, one, two, zero, shortTopic, user.getUserId());
    }
}
